/*
 * Copyright 2008 the original author Ang Gao.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * menubar.java 2008-12-16
 */
package ie.ucc.cs.anggao.finalproject.client.ui.mainpanel.editorpane.menubar;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.RichTextArea;

/**
 * @author GaoAng
 * 
 */
public class menuBar extends Composite {

	private MenuBar fileMenu;
	private MenuBar editMenu;
	private MenuBar settingMenu;
	private MenuBar helpMenu;
	private MenuBar menu;
	private RichTextArea richtextarea;
	public menuBar(RichTextArea richtextarea) {
		this.richtextarea = richtextarea;
		// Make a command that we will execute from all leaves.
		Command cmd = new Command() {
			public void execute() {
				Window.alert("You selected a menu item!");
			}
		};
		
		
		Command newfile = new Command() {
			
			public void execute() {
				menuBar.this.richtextarea.setText("");
			}
		};
		
		Command about = new Command() {
			public void execute() {
				Window.alert("JITIR Editor--Ang Gao");
			}
		};
		
		menu = new MenuBar();
		menu.setAutoOpen(false);
		menu.setAnimationEnabled(true);

		fileMenu = new MenuBar(true);
		fileMenu.setAnimationEnabled(true);
		fileMenu.addItem("New", newfile);
		fileMenu.addItem("Open", cmd);
		fileMenu.addItem("Close", newfile);
		fileMenu.addSeparator();
		fileMenu.addItem("Exit", cmd);
		
		
		editMenu = new MenuBar(true);
		editMenu.setAnimationEnabled(true);
		editMenu.addItem("Undo", cmd);
		editMenu.addItem("Redo", cmd);
		editMenu.addItem("Cut", cmd);
		editMenu.addItem("Copy", cmd);
		editMenu.addItem("Pase", cmd);

		settingMenu = new MenuBar(true);
		settingMenu.setAnimationEnabled(true);
		settingMenu.addItem("Searcher", cmd);
		settingMenu.addItem("Result Number", cmd);
		settingMenu.addItem("Time to refresh", cmd);

		helpMenu = new MenuBar(true);
		helpMenu.setAnimationEnabled(true);
		helpMenu.addItem("Contents", cmd);
		helpMenu.addItem("About", about);

		menu.addItem("File", fileMenu);
		menu.addItem("Edit", editMenu);
		menu.addItem("Setting", settingMenu);
		menu.addSeparator();
		menu.addItem("Help", helpMenu);
		initWidget(menu);

	}

}
